/*
 * @Author: Zeratul
 * @Date: 2020-08-28 02:40:33
 * @LastEditTime: 2020-08-28 13:35:49
 * @FilePath: \sz-h5-2003-react-mobile\zhangminhui\eleme-react\eleme-user\src\store\reducer\chatReducer\index.js
 */

import { GETMESSAGE, CHANGEINPUTVAL, SENDMESSAGE } from "../../actionType";
const defaultState = {
  message: [],
  inpValue:''
};

export default function (state = defaultState, action) {
  let newState = JSON.parse(JSON.stringify(state));
  switch (action.type) {
    case GETMESSAGE:
      newState.message.push({
        time: Date.now(),
        message: action.message,
        direction:"left",
        img:"http://175.24.122.212:9090/uploads/6666/resize_w_150.jpg"
      });
      break;
      case CHANGEINPUTVAL:
        newState.inpValue = action.message.trim();
      break;
      case SENDMESSAGE:
        newState.inpValue = "";
        break;
      default:
        break;
  }

  return newState;
}
